<template>
	<view class="content autnstatus-cnt">
		<image v-if="isGet != '1'" class="autnstatus-icon" :src="type == 1 ? '/static/images/autn_status3.png' : '/static/images/autn_status2.png'"></image>
		<image v-else class="autnstatus-icon" :src="type == 1 ? '/static/images/autn_status.png' : '/static/images/autn_status2.png'"></image>
		<view v-if="type == 1" class="auth-msg f-32">{{isGet=='1' ? '领取' : '提交'}}成功！</view>
		<view v-else class="auth-msg f-32 fail">{{isGet=='1' ? '领取' : '提交'}}失败</view>
		
		<view v-if="type == 1 && isGet != '1'"  class="auto-tip f-28">等待管理员审核签发后生效</view>
		<view class="auto-tip2 f-28">{{msg || '生效后可在个人账号中出示使用'}}</view>
		<!-- <view class="btn-box">
			<view @click="goback" class="btn second-style">返回</view>
			<view  v-if="type == 1" @click="getCard" class="btn">申领证件</view>
			<view v-else @click="goback" class="btn">重新认证</view>
		</view> -->
		<view class="flexbox flexbox-center flexbox-middle time-tip"> <text>{{time}}</text>秒后将跳往首页</view>
		<view class="btn-box">
			<view v-if="type == 1" @click="getTo('/pages/myWorcard/index')" class="btn big-btn">查看我的工作证</view>
			<!-- <view  @click="gethome('/pages/index/index')" class="btn second-style">返回首页</view> -->
		</view>
		
	</view>

</template>

<script>
	export default {
		data() {
			return {
				msg: '',
				type: '1', // 1成功   2 失败
				time: 5,
				timer: null,
				isGet: 0
			}
		},
		onLoad: function(e) {
			let ctid = e.ctid || ''
			if (ctid) {
				uni.setStorageSync('ctid', ctid);
			}
			this.type = e.type || '1'
			this.msg = e.msg || ''
			this.isGet = e.isGet
			this.timer = setInterval(() => {
				this.time-- 
				if (this.time <= 0) {
					clearInterval(this.timer)
					uni.switchTab({
					    url: '/pages/index/index'
					});
					return false
				}
			}, 1000)
		},
		methods: {
			goback() {
				uni.navigateBack({
				    delta: 2
				});
			},
			getTo(url) {
				uni.navigateTo({
				    url: url
				});
			},
			gethome(url) {
				uni.switchTab({
				    url: url
				});
			},
			getCard() {
				uni.navigateTo({
				    url: '/pages/applyCertificate/index'
				});
			},
		},
		onHide() {
			if (this.timer) {
				clearInterval(this.timer)
			}
		},
		onUnload() {
			if (this.timer) {
				clearInterval(this.timer)
			}
		}

	}
</script>

<style lang="scss" scoped>
	.autnstatus-cnt {
		text-align: center;
		.autnstatus-icon {
			width: 324rpx;
			height: 329rpx;
			margin: 91rpx auto 40rpx auto;
		}
		.auth-msg {
			margin-bottom: 32rpx;
			color: #333333;
			font-weight: bold;
		}
		.auth-msg.fail {
			color: #FF6868;
		}
		.auto-tip {
			margin: 32rpx 86rpx 0 86rpx;
			color: #FF984E;
		}
		.auto-tip2 {
			margin-top: 4rpx;
			color: #999;
		}
	}
	.btn-box {
		margin-top: 194rpx;
		.btn {
			display: inline-block;
			width: 460rpx;
			height: 84rpx;
			margin: 20rpx 42rpx;
			background: #0579FE;
			border: 1rpx solid #0579FE;
			border-radius: 66rpx;
			color: #FFFFFF;
			line-height: 84rpx;
		}
		.second-style {
			background: #FFFFFF;
			color: #0579FE;
		}
		.big-btn {
			width: 454rpx;
			height: 93rpx;
			background: #0579FE;
			box-shadow: 0px 6rpx 16rpx 0px rgba(5, 121, 254, 0.4);
			border-radius: 47rpx;
			line-height: 93rpx;
		}
	}
	.time-tip {
		margin: 40rpx 0 10rpx 0;
		color: #666666;
		text {
			margin: 0 6rpx;
			color: #0579FE;
		}
	}
</style>
